import {deviceApi} from "../../model/aliyun/device";

Component({
    properties: {
        statusTitle: {
            type: String,
            value: '',
        },
        deviceType: {
            type: String,
            value: '',
        },
        deviceList: {
            type: Array,
            value: []
        },
    },
    methods: {
        handleDeviceAction(e) {
            console.log('deviceList', e);
            if (this.data.deviceType === 'OffLine'){
                wx.showToast({ title: '此设备已离线', icon: 'none' });
            } else if (this.data.deviceType === 'Unative') {
                wx.showToast({ title: '此设备未激活', icon: 'none' });
            } else if (this.data.deviceType === 'Disable') {
                wx.showToast({ title: '此设备已禁用', icon: 'none' });
            } else {
                const { iotid } = e.currentTarget.dataset;
                let params = {
                    IotId: iotid,
                    Items: JSON.stringify({status:0})
                };
                deviceApi.setDeviceProperty(
                    params
                ).then(res => {
                    console.log(res);
                }).catch(err => {
                    console.log(err);
                });
            }
        }
    }
});
